home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / Basic Classes / Z Headers / ZApplication.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-30  |  4.0 KB  |  156 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZApplication.h            -- the application object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22. #pragma once
  23.  
  24. #ifndef __ZAPPLICATION__
  25. #define    __ZAPPLICATION__
  26.  
  27. #ifndef __ZCOMMANDER__
  28. #include    "ZCommander.h"
  29. #endif
  30.  
  31. class    ZEventHandler;
  32. class    ZWindow;
  33. class    ZUndoTask;
  34. class    ZPrinter;
  35. class    ZMenuBar;
  36.  
  37. class    ZApplication : public ZCommander
  38. {
  39. protected:
  40.  
  41.     Boolean            done;                // normally FALSE, if set TRUE, will try to quit
  42.     short            phase;                // current phase
  43.     short            appResRefNum;        // refnum of application resource file
  44.     ZEventHandler*    zEH;                // event handler object
  45.     ZWindow*        mostRecent;            // most recently created window
  46.     Handle            shortageFund;        // to deal with tight memory, we can release this
  47.     OSType**        itsFileTypes;        // list of filetypes we can open
  48.     ZUndoTask*        curUndoTask;        // current undoable task
  49.     ZPrinter*        itsPrinter;            // printer object for handling print commands
  50.  
  51. public:    
  52.     Boolean            memIsShort;            // flag memory problem
  53.     Boolean            userHasSeenAlert;    // TRUE if user has been warned about the memory
  54.  
  55.     ZApplication();
  56.     virtual ~ZApplication();
  57.     
  58.     // initialisation and clean-up
  59.     
  60.     virtual void        InitMacZoop( const short numMasterBlocks = 8 );
  61.     virtual void        StartUp() {};
  62.     virtual void        ShutDown() {};
  63.     virtual void        ReadPrefs() {};
  64.     
  65.     // event processing
  66.     
  67.     virtual void        Run();
  68.     virtual Boolean        Quit();
  69.     virtual void        RequestQuit();
  70.     virtual Boolean        MemoryShortage( const Size bytesShort );
  71.     virtual void        Process1Event();
  72.     virtual void        HandleCommand( const long aCmd );
  73.     virtual void        HandleCommand( const short menuID, const short itemID );
  74.     virtual void        UpdateMenus();
  75.     virtual Boolean        GetCurrentEvent( EventRecord* anEvent );
  76.     virtual void        HandleAppleEvent(    AEEventClass aeClass, AEEventID aeID,
  77.                                             AppleEvent* aeEvt, AppleEvent* reply );
  78.     virtual void        ProcessHLEvent( const EventRecord& theEvt ) {};
  79.  
  80.     // error processing
  81.     
  82.     virtual void        HandleError( OSErr theErr );
  83.     
  84.     // window construction
  85.     
  86.     virtual void        OpenNewWindow();
  87.     virtual void        CloseAll( Boolean closeFloaters = FALSE );
  88.     virtual ZWindow*    GetFrontWindow();
  89.     virtual void        AboutBox();
  90.     
  91.     // opening files
  92.     
  93.     virtual Boolean        PickFile( FSSpec* aFile, OSType* fType );
  94.     virtual void        OpenFile( const FSSpec& aFile, const OSType fType );
  95.     
  96.     // extending the file types
  97.     
  98.     virtual void        AddFileType( const OSType aType );
  99.     
  100.     // undo task handling
  101.     
  102.     virtual void        SetTask( ZUndoTask* aTask );
  103.     virtual void        UpdateUndo();
  104.     inline ZUndoTask*    GetUndoTask() { return curUndoTask; };
  105.     
  106.     // printer handling
  107.     
  108.     virtual void        MakePrinter();
  109.     virtual void        DoPageSetup();
  110.     virtual void        DoPrint();
  111.     inline    ZPrinter*    GetPrinter() { return itsPrinter; };
  112.  
  113.     // other inline accessors
  114.     
  115.     inline    short        GetPhase(){ return phase;};
  116.     inline    OSType**    GetFileTypeList() { return itsFileTypes; };
  117.     inline    short        GetClicks();
  118.     inline    Boolean        InBackground();
  119.     inline    ZEventHandler*    GetEventHandler() { return zEH; };
  120.     
  121.     virtual void        GetName( Str255 appName );
  122.     inline    short        GetAppRefnum() { return appResRefNum; };
  123.     
  124. protected:
  125.  
  126.     void                InitMacApplication( const short numMasterBlocks );
  127.     virtual void        MakeEventHandler();
  128.     virtual void        MakeClipboard();
  129.     virtual Boolean        CheckCanRun();
  130.     virtual void        InitMenuBar();
  131.     virtual void        MakeNewWindow();
  132.     virtual void        CheckLowMemory();
  133. };
  134.  
  135. // possible values of "phase"
  136.  
  137. enum
  138. {
  139.     kInitialising,
  140.     kRunning,
  141.     kQuitting
  142. };
  143.  
  144. #define        kUndoStrIndex        5
  145. #define        kRedoStrIndex        6
  146. #define        kCantUndoStrIndex    7        
  147.  
  148. #define        kCantRunAlertID        131
  149.  
  150. // By default, MacZoop will work like a normal Mac application in that it will open a new
  151. // "untitled" window at startup if no files are passed to it. If you want to make a "faceless"
  152. // application, comment IN the following define to suppress the opening of the initial window.
  153.  
  154. //#define        NO_UNTITLED_STARTUP_WINDOW        1
  155.  
  156. #endif